Skip to content

Document LLMObs trace sampling controls for Python and Node.js SDKs#37602

Draft
Yun-Kim wants to merge 3 commits into
masterfrom
yun.kim/llmobs-sampling-docs
Draft

Document LLMObs trace sampling controls for Python and Node.js SDKs#37602
Yun-Kim wants to merge 3 commits into
masterfrom
yun.kim/llmobs-sampling-docs

Conversation

@Yun-Kim

@Yun-Kim Yun-Kim commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

What

Documents Python and Node.js LLM Observability (Agent Observability) trace sampling controls in the SDK reference (instrumentation/sdk.md):

Python:

  • DD_LLMOBS_SAMPLE_RATE environment variable — added to the Python command-line setup env-var list (float 0.01.0, default 1.0).
  • sample_rate parameter on LLMObs.enable() — added to the Python in-code setup parameters, following dd-trace-py#18607. Documents precedence (sample_rate arg > DD_LLMOBS_SAMPLE_RATE > default 1.0) and that out-of-range values are ignored.

Node.js (assumes dd-trace-js#9030 merges):

  • DD_LLMOBS_SAMPLE_RATE environment variable — added to the Node.js command-line setup env-var list (float, default 1.0).
  • sampleRate parameter under llmobs in tracer.init({ llmobs: { sampleRate } }) — added to the Node.js in-code setup parameters. Documents precedence (sampleRate > DD_LLMOBS_SAMPLE_RATE > default 1).

In the Node.js SDK the keep/drop decision is computed once on the root span, inherited by descendants, and propagated across services via x-datadog-tags; spans are always shipped and the decision is applied during ingestion.

Why

Neither control was documented anywhere in content/en/llm_observability/. The existing docs only cover server-side/UI sampling (automation rules, annotation queues, datasets, custom judges), so there was no reference for client-side, pre-ingestion trace sampling in the SDK.

Scope notes

  • Python and Node.js. Java does not expose these controls, so its tabs are intentionally untouched.
  • No retention/limits content added — this PR is scoped to sampling mechanisms only.
  • Cross-links to automation rules and APM ingestion mechanisms; both targets verified to exist.

Claude session: `8bc9e12c-8440-4689-a2dc-e2f1f1ad66ae`
Resume: `claude --resume 8bc9e12c-8440-4689-a2dc-e2f1f1ad66ae`

🤖 Generated with Claude Code

Add DD_LLMOBS_SAMPLE_RATE (command-line setup) and the new sample_rate
parameter on LLMObs.enable() (in-code setup) to the Agent Observability
SDK reference. Python-only; not supported in the Node.js or Java SDKs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Preview links (active after the build_preview check completes)

Modified Files

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Yun-Kim Yun-Kim changed the title Document LLMObs trace sampling controls for Python SDK Document LLMObs trace sampling controls for Python and Node.js SDKs Jun 24, 2026

`DD_LLMOBS_SAMPLE_RATE`
: optional - _float_ - **default**: `1.0`
<br />The fraction of traces to submit to Agent Observability, between `0.0` (drop everything) and `1.0` (submit everything). The sampling decision is made on the root span and inherited by all of its child spans, so a trace is always kept or dropped as a whole. The decision is also propagated to downstream services, keeping distributed traces intact. This client-side sampling happens before ingestion and is independent of in-app controls such as [automation rules][2]. It does not affect [APM trace sampling][3], and APM sampling does not drop Agent Observability data.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<br />The fraction of traces to submit to Agent Observability, between `0.0` (drop everything) and `1.0` (submit everything). The sampling decision is made on the root span and inherited by all of its child spans, so a trace is always kept or dropped as a whole. The decision is also propagated to downstream services, keeping distributed traces intact. This client-side sampling happens before ingestion and is independent of in-app controls such as [automation rules][2]. It does not affect [APM trace sampling][3], and APM sampling does not drop Agent Observability data.
<br />The fraction of traces to submit to Agent Observability, between `0.0` (drop everything) and `1.0` (submit everything). The sampling decision is made on the root span and inherited by all of its child spans (including downstream services). This sampling is independent of in-app controls such as [automation rules][2] and [APM trace sampling][3].


`DD_LLMOBS_SAMPLE_RATE`
: optional - _float_ - **default**: `1.0`
<br />The proportion of traces to sample for Agent Observability, between `0.0` (drop everything) and `1.0` (keep everything). The sampling decision is computed once on the root span, inherited by all of its child spans, and propagated to downstream services, so a distributed trace is kept or dropped as a whole. Spans are always sent to Datadog, and the sampling decision is applied during ingestion. This is independent of in-app controls such as [automation rules][2], and does not affect [APM trace sampling][3].

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same suggestion as above (python)


`sample_rate`
: optional - _float_
<br />The fraction of traces to submit to Agent Observability, between `0.0` (drop everything) and `1.0` (submit everything). The sampling decision is made on the root span and inherited by all of its child spans, so a trace is always kept or dropped as a whole. Values outside the `[0.0, 1.0]` range are ignored. This takes precedence over `DD_LLMOBS_SAMPLE_RATE`; if not provided, this defaults to the value of that environment variable (`1.0` if unset).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<br />The fraction of traces to submit to Agent Observability, between `0.0` (drop everything) and `1.0` (submit everything). The sampling decision is made on the root span and inherited by all of its child spans, so a trace is always kept or dropped as a whole. Values outside the `[0.0, 1.0]` range are ignored. This takes precedence over `DD_LLMOBS_SAMPLE_RATE`; if not provided, this defaults to the value of that environment variable (`1.0` if unset).
<br />The fraction of traces to submit to Agent Observability, between `0.0` (drop everything) and `1.0` (submit everything). The sampling decision is made on the root span and inherited by all of its child spans (including downstream services). If unset, this defaults to `DD_LLMOBS_SAMPLE_RATE`, but otherwise takes precedence over the environment variable.


`sampleRate`
: optional - _number_
<br />The proportion of traces to sample for Agent Observability, between `0` and `1` (inclusive). The sampling decision is computed once on the root span, inherited by all of its child spans, and propagated to downstream services, so a distributed trace is kept or dropped as a whole. This takes precedence over `DD_LLMOBS_SAMPLE_RATE`; if not provided, it defaults to the value of that environment variable (`1` if unset).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment for Python inline config

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants